var isBoss = false;
var isFa = true;
var isNO = true;
var isElectronic = true;
var reviewer_rs_draw = new Ext.data.JsonReader({
    root: 'manuscripts',
    totalProperty: 'totalCount'
}, [{
    name: 'urgence',// 紧急程度，取值见urgence常量
    mapping: 'urgence',
    hidden: 'true'
}, {
    name: 'workerStatu',// 人员状态
    mapping: 'manuscriptWorks',
    hidden: 'true'
}, {
    name: 'securityClassification',// 密级，取值见securityClassification常量
    mapping: 'securityClassification',
    hidden: 'true'
}, {
    name: 'manuscriptId',// 稿件标识
    mapping: 'manuscriptId',
    hidden: 'true'
}, {
    name: 'title',// 稿件标题
    mapping: 'title',
    convert: function(v, rec){
        if (v.length > 15) {
            return v.substring(0, 15) + "...";
        }
        else {
            return v;
        }
    }
}, {
    name: 'contributeCompanyName',// 来稿单位
    mapping: 'contributeCompany.contributeCompanyName'
}, {
    name: 'manuscriptWorks',// 判断是否统稿人
    mapping: 'manuscriptWorks',
    hidden: 'true'
}, {
    name: 'manuscriptCategoryName',// 稿件分类
    mapping: 'manuscriptCategory.manuscriptCategoryName'
}, {
    name: 'plannedConsummationTime',// 计划完成时间
    mapping: 'manuscriptWorks',
    convert: function(v, rec){
        return v[0].plannedFinishedTime;
    }
}, {
    name: 'createdTimestamp',// 稿件工作创建时间
    mapping: 'manuscriptWorks',
    convert: function(v, rec){
        return v[0].createdTimestamp;
    }
}]);

var reviewer_ds_draw = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        url: 'reviewer_listManuscriptWorksForWorker_list.action',
        method: 'POST'
    }),
    reader: reviewer_rs_draw
});
var reviewer_cm_draw = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
    header: "稿件标题",
    width: 100,
    dataIndex: 'title',
    sortable: true,
    renderer: function(value, metadata, record){
        return "<a href = 'javascript:void(0)' onclick=javascript:reviewer_showdrawView('" +
        record.data.manuscriptId +
        "')> " +
         escapeHTML(value) +
        " </a>";
    }
}, {
    header: "来稿单位",
    width: 120,
    dataIndex: 'contributeCompanyName'

}, {
    header: "稿件分类",
    width: 120,
    dataIndex: 'manuscriptCategoryName'

}, {
    header: "要求完成时间",
    width: 120,
    dataIndex: 'plannedConsummationTime',
    sortable: true,
    renderer: function(value, metadata, record){
	 	return new Date(value).format('Y-m-d');
    }
}, {
    header: "标识",
    width: 120,
    dataIndex: 'manuscriptId',
    renderer: function(value, metadata, record){
        return tomark(value, metadata, record);
        
    }
}, {
    header: "操作",
    width: 120,
    dataIndex: 'manuscriptId',
    renderer: function(value, metadata, record){
    
        return touserCheck(value, metadata, record);
    }
}]);
// 操作START

function touserCheck(value, metadata, record){
    if (record.data.manuscriptWorks[0].principalId == userId) {
        isBoss = true;
    }
    else {
        isBoss = false;
    }
    if (isBoss == true || ((record.data.manuscriptWorks[0].status > 1) && (record.data.manuscriptWorks[0].manuscriptWorkers[0].status == 1))) {
        return "<a href = 'javascript:void(0)' onclick=javascript:reviewer_draw('canDownLoad','" +
        record.data.manuscriptId +
        "')>领稿 </a> <a href='javascript:void(0)' onclick=javascript:reviewer_refuse('" +
        record.data.manuscriptId +
        "')>拒绝</a>";
    }
    else {
        return "<a href = 'javascript:void(0)'  onclick=javascript:reviewer_draw('noDownLoad','" +
        record.data.manuscriptId +
        "')>查看 </a>";
    }
}

// 操作END
function tolastModifierName(value){

    if (value == null) {
        return "";
    }
    else {
        return value;
    }
    
}

// 时间操作START
function totime(value, metadata, record){
    return new Date(value).format('Y-m-d H:i');
    
}

function tomyWordnum(value){
    for (var i = 0; i < value.length; i++) {
        if (value[i].manuscriptWorkerId == userId) {
            return value[i].wordNum;
        }
        
    };
    }

// 时间操作END
// 来稿START
function toisBoss(value){
    if (value == userId) {
        return true;
    }
    else {
        return false;
    }
}

function tourgence(value){

    switch (value) {
        case 0:
            return "普通";
            break;
        case 5:
            return "紧急";
            break;
        case 10:
            return "特急";
            break;
    }
}

function toisElectronic(value){
    switch (value) {
        case 0:
            return false;
            break;
        case 0x0100:
            return true;
            break;
    }
    
}

function tosecurityClassification(value){

    switch (value) {
        case 1:
            return "普通";
            break;
        case 2:
            return "秘密";
            break;
        case 3:
            return "机密";
            break;
        case 5:
            return "绝密";
            break;
    }
    
}

function tolanguage(value){

    switch (value) {
        case 1:
            return "汉语";
            break;
        case 2:
            return "藏语";
            break;
    }
    
}

function totargetLanguage(value){

    switch (value) {
        case 1:
            return "汉语";
            break;
        case 2:
            return "藏语";
            break;
    }
    
}

function totexttype(value){

    switch (value) {
        case 0:
            return "纸质稿件";
            break;
        case 0x0100:
            return "电子稿件";
            break;
    }
    
}

function totype(value) {
	if(value=="DW"){
		return "党委";
	}else if(value=="RD"){
		return "人大";
	}else if(value=="ZF"){
		return "政府";
	}else if(value=="ZX"){
		return "政协";
	}else if(value=="QT"){
		return "其他";
	}else{
		return value;
	}
}

function tomanuscriptWorkerName(value){
    var mw = value.manuscriptWorkers;
    var names = "";
    for (var i = 0; i < mw.length; i++) {
        names += mw[i].manuscriptWorkerName + " ";
    };
    if (mw.length == 0) {
        isNO = false;
        return "";
    }
    else {
        return names;
    }
}

function toisFa(value){
    var sta = 0;
    for (var i = 0; i < value.manuscriptWorkers.length; i++) {
        if (userId == value.manuscriptWorkers[i].manuscriptWorkerId) {
            sta = value.manuscriptWorkers[i].status;
        }
    };
    var valu = value.manuscriptWork.status;
    if (valu > 1 && sta == 1) {
        return true;
    }
    else {
        return false;
    }
    
    
}

// 来稿END
// 表单START
var urgence;
var securityClassification;
var language;
var targetLanguage;
var contributeTime;
var plannedConsummationTime;
var createdTimestamp;
var type;
var texttype;
var manuscriptWorkerName;
var lastModifierName;
var myWordnum;
var jhplannedConsummationTime;
function formchange(respText){
    myWordnum = tomyWordnum(respText.manuscriptWorkers2);
    lastModifierName = tolastModifierName(respText.manuscript.lastModifierName);
    isElectronic = toisElectronic(respText.manuscript.type);
    isFa = toisFa(respText);
    isBoss = toisBoss(respText.manuscriptWork.principalId);
    urgence = tourgence(respText.manuscript.urgence);
    securityClassification = tosecurityClassification(respText.manuscript.securityClassification);
    language = tolanguage(respText.manuscript.language);
    targetLanguage = totargetLanguage(respText.manuscript.targetLanguage);
    contributeTime = totime(respText.manuscript.contributeTime, "", "");
    plannedConsummationTime = totime(respText.manuscriptWork.plannedFinishedTime, "", "");
    createdTimestamp= totime(respText.manuscriptWork.createdTimestamp,"","");
    texttype = totexttype(respText.manuscript.type);
    type = totype(respText.contributeCompany.type);
    manuscriptWorkerName = tomanuscriptWorkerName(respText);
    jhplannedConsummationTime=totime(respText.manuscript.plannedConsummationTime,"","");
}

// 表单END
// 标志START  
var re;
function tomark(value, metadata, record) {
    var title = '&nbsp;密级&nbsp;&nbsp;&nbsp;&nbsp;紧急程度&nbsp;';
    var tip;
    var s1 = "&nbsp;普通&nbsp;&nbsp;&nbsp;&nbsp;";
    var s2 = "&nbsp;秘密&nbsp;&nbsp;&nbsp;&nbsp;";
    var s3 = "&nbsp;机密&nbsp;&nbsp;&nbsp;&nbsp;";
    var s5 = "&nbsp;绝密&nbsp;&nbsp;&nbsp;&nbsp;";
    var u0 = "&nbsp;&nbsp;&nbsp;普通&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    var u5 = "&nbsp;&nbsp;&nbsp;紧急&nbsp;&nbsp;&nbsp;&nbsp;";
    var u10 = "&nbsp;&nbsp;&nbsp;特急";
    var c0 = "&nbsp<img src='images/clock_blue.gif'  />&nbsp";// 普通urgence
    var c5 = "&nbsp<img src='images/clock_green.gif' />&nbsp";// 紧急
    var c10 = "&nbsp<img src='images/clock_red.gif' />&nbsp";// 特急
    var l1 = "&nbsp<img src='images/lock_blue.gif'  />&nbsp";// 普通securityClassification
    var l2 = "&nbsp<img src='images/lock_gold.gif'/>&nbsp"; // 秘密
    var l3 = "&nbsp<img src='images/lock_green.gif' />&nbsp";// 机密
    var l5 = "&nbsp<img src='images/lock_red.gif'  />&nbsp";// 绝密
    switch (record.data.securityClassification) {
        case 1:
            switch (record.data.urgence) {
                case 0:
                	re = l1 + c0;
                    tip = s1 + u0;
                    break;
                case 5:
                	re = l1 + c5 ;
                    tip = s1 + u5;
                    break;
                case 10:
                	re = l1 + c10;
                    tip = s1 + u10;
                    break;
            }
            break;
        case 2:
            switch (record.data.urgence) {
                case 0:
                	re = l2 + c0;
                    tip = s2 + u0;
                    break;
                case 5:
                	re = l2 + c5;
                    tip = s2 + u5;
                    break;
                case 10:
                	re = l2 + c10;
                    tip = s2 + u10;
                    break;
            }
            break;
        case 3:
            switch (record.data.urgence) {
	            case 0:
	            	re = l3 + c0;
	                tip = s3 + u0;
	                break;
	            case 5:
	            	re = l3 + c5;
	                tip = s3 + u5;
	                break;
	            case 10:
	            	re = l3 + c10;
	                tip = s3 + u10;
	                break;
            }
            
            break;
        case 5:
            switch (record.data.urgence) {
	            case 0:
	            	re = l5 + c0;
	                tip = s5 + u0;
	                break;
	            case 5:
	            	re = l5 + c5;
	                tip = s5 + u5;
	                break;
	            case 10:
	            	re = l5 + c10;
	                tip = s5 + u10;
	                break;
	            }
            break;
    }
    metadata.attr = 'ext:qtitle="' + title + '"' + ' ext:qtip="' + tip + '"';
    return re;
}

// 标志END

// 查看稿件
window.reviewer_showdrawView = function(needParam){
    Ext.Ajax.request({
        url: 'reviewer_listoneManuscript_view.action',
        method: 'post',
        params: {
            manuscriptId: needParam
        },
        success: function(resp, opts){
            var respText = Ext.util.JSON.decode(resp.responseText);
            if (respText.success) {
                formchange(respText);
                var reviewer_window_drawView = new Ext.Window({
                    closable: false,
                    title: '稿件详情',
                    width: 600,
                    resizable: false,
                    autoHeight: true,
                    modal: true,
                    iconCls: 'manuscript',
                    constrain: true,
                    closeAction: 'hide',
                    items: [new Ext.FormPanel({
                        border: false,
                        labelAlign: 'right',
                        labelWidth: 100,
                        frame: true,
                        items: [{
                            fieldLabel: '稿件标题',
                            xtype: 'textfield',
                            readOnly: true,
                            width: 425,
                            itemCls: "form_long unedit",
                            value: respText.manuscript.title
                        },{
							autoHeight : true,
							xtype : 'textfield',
							fieldLabel : '稿件编号',
							readOnly : true,
							value : respText.manuscript.manuscriptCode,
							itemCls:'form_text unedit'
						}, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '来稿单位',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.contributeCompany.contributeCompanyName
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '来稿单位类型',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: type
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '联系人',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.contributeCompanyPerson.name
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '联系人手机',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.contributeCompanyPerson.mobilePhone
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '联系人邮箱',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.contributeCompanyPerson.email
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '稿件分类',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.manuscriptCategory.manuscriptCategoryName
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '紧急程度',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: urgence
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '文档类型',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: texttype
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '原稿文种',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: language
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '密级',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: securityClassification
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '目标语言',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: targetLanguage
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '字数',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.manuscript.wordNum
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '来稿时间',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: contributeTime
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '计划完成时间',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: jhplannedConsummationTime
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '创建人',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.manuscript.creatorName
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '最后修改人',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: lastModifierName
                        
                        }, {
                            fieldLabel: '备注',
                            xtype: 'panel',
                            width: 425,
                            itemCls: 'clear',
                            html: changeRemark(respText)
                        }],
                        buttons: [{
                            text: '关闭',
                            handler: function(){
                                reviewer_window_drawView.hide();
                            }
                        }]
                    })]
                
                }).show();
            }
            else {
                Ext.Msg.alert('查看详情失败');
            }
        },
        failure: function(){
            Ext.Msg.show({
                title: '错误提示',
                msg: '查看失败!',
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.ERROR,
                width: 200
            });
        }
    });
}
function changeRemark(respText){
    return "<div align=\"center\"><a href='javascript:void(0)'  onclick=javascript:showRemark('" + respText.manuscript.manuscriptId + "')>备注详情</a></div>";
}

window.showRemark = function(v){
    Ext.Ajax.request({
        url: 'reviewer_listoneManuscript_view.action',
        method: 'post',
        params: {
            manuscriptId: v
        },
        success: function(resp, opts){
            var respText = Ext.util.JSON.decode(resp.responseText);
            if (respText.success) {
                var window_remark = new Ext.Window({
                    title: '备注详情',
                    closable: false,
                    width: 600,
                    resizable: false,
                    height: 400,
                    iconCls: 'manuscript',
                    modal: true,
                    constrain: true,
                    closeAction: 'close',
                    layout: 'fit',
                    items: [{
                        xtype: 'htmleditor',
                        enableAlignments: false,
                        enableColors: false,
                        enableFont: false,
                        enableFontSize: false,
                        enableFormat: false,
                        enableLinks: false,
                        enableLists: false,
                        enableSourceEdit: false,
                        readOnly: true,
                        value: respText.manuscript.remark
                    }],
                    buttons: [{
                        text: '关闭',
                        handler: function(){
                            window_remark.close();
                        }
                    }]
                
                
                }).show();
            }
        },
        failure: function(){
            Ext.Msg.show({
                title: '错误提示',
                msg: '查看失败!',
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.ERROR,
                width: 200
            });
        }
    })
}
/*
 * 下载原稿START
 */
window.reviewer_myUpload = function(refEntityId, refEntityType){
    Ext.Ajax.request({
        url: 'reviewer_downloadManuscript_download.action',
        method: 'post',
        params: {
	    	refEntityId: refEntityId,
	        refEntityType:refEntityType
        },
        success: function(resp, opts){
            var respText = Ext.util.JSON.decode(resp.responseText);
            if (respText.success) {
                if (respText.entityPaths != null) {
                    download(respText.entityPaths, refEntityId, refEntityType);
                }
                else {
                    Ext.Msg.show({
                        title: '错误提示',
                        msg: respText.msg,
                        buttons: Ext.Msg.OK,
                        icon: Ext.Msg.ERROR,
                        width: 200
                    });
                }
            }
            else {
                Ext.Msg.show({
                    title: '错误提示',
                    msg: respText.msg,
                    buttons: Ext.Msg.OK,
                    icon: Ext.Msg.ERROR,
                    width: 200
                });
            }
        },
        failure: function(){
            Ext.Msg.show({
                title: '错误提示',
                msg: '没有附件!',
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.ERROR,
                width: 200
            });
        }
    });
}
function download(entityPaths, refEntityId, refEntityType){
    var path = "download.action?inputPath=" + entityPaths + "&refEntityId=" + refEntityId + "&refEntityType=" + refEntityType;
    window.location.href = path;
}

/*
 * 下载原稿END\
 */
function getFormconfirm(f, respText, myhtml){
	var mm = {
			id: 'myAdd',
			autoHeight: true,
			fieldLabel: '下载稿件',
			xtype: 'panel',
			width: 425,
			itemCls: 'clear',
			html: myhtml
	};
	f.add(mm);
//    if (respText.manuscript.type == 0x0100) {
//    }
    
}

/*
 * 查看稿件END
 */
// 领稿操作START
window.reviewer_draw = function(isCanDownLoad,needParam){
    Ext.Ajax.request({
        url: 'reviewer_listoneManuscript_view.action',
        method: 'post',
        params: {
            manuscriptId: needParam
        },
        success: function(resp, opts){
            var respText = Ext.util.JSON.decode(resp.responseText);
            if (respText.success) {
                formchange(respText);
                if('canDownLoad'==isCanDownLoad){
                	if(isBoss){
                		var myhtml = "<div align=\"center\"><a href=javascript:void(0) onclick=javascript:reviewer_myUpload(" + respText.manuscript.manuscriptId + ",'Manuscript')>下载原稿</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=javascript:void(0) onclick=javascript:reviewer_myUpload(" + respText.achieveManuscriptWork[2].manuscriptWorkId + ",'ManuscriptWork')>下载校对稿</a></div>";
                	}else{
                		var myhtml = "<div align=\"center\"><a href=javascript:void(0) onclick=javascript:reviewer_myUpload(" + respText.manuscript.manuscriptId + ",'ManuscriptReviewTask')>下载审核任务分配稿</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=javascript:void(0) onclick=javascript:reviewer_myUpload(" + respText.achieveManuscriptWork[2].manuscriptWorkId + ",'ManuscriptWork')>下载校对稿</a></div>";
                	}
                }else {
                	var myhtml = "<div align=\"center\"><span style='color:#CCCCCC'>下载审核任务分配稿</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='color:#CCCCCC'>下载校对稿</span></div>";
                }
                
                if ((isBoss) || (isFa)) {
                    var reviewer_form = new Ext.FormPanel({
                        border: false,
                        labelAlign: 'right',
                        labelWidth: 100,
                        frame: true,
                        items: [{
                            fieldLabel: '稿件标题',
                            xtype: 'textfield',
                            readOnly: true,
                            itemCls: "unedit",
                            width: 425,
                            value: respText.manuscript.title
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '来稿单位',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.contributeCompany.contributeCompanyName
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '要求完成时间',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: plannedConsummationTime
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '字数',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: myWordnum
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '统稿人',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.manuscriptWork.principalName
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '小组成员',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: manuscriptWorkerName
                        
                        },  {
                            autoHeight: true,
                            xtype: 'textarea',
                            fieldLabel: '任务描述',
                            readOnly: true,
                            width: 425,
                            itemCls: 'clear unedit',
                            value: respText.manuscriptWork.description
                        
                        }],
                        buttons: [{
                            text: '确定',
                            handler: function(){
                            
                                Ext.Ajax.request({
                                    url: 'reviewer_manuscriptWorkerAcceptWork_accept.action',
                                    method: 'post',
                                    params: {
                                        manuscriptWorkId: respText.manuscriptWork.manuscriptWorkId,
                                        isBoss: isBoss,
                                        electronic: isElectronic
                                    },
                                    success: function(resp, opts){
                                        var respText = Ext.util.JSON.decode(resp.responseText);
                                        if (respText.success) {
                                            reviewer_window_draw.close();
                                            reviewer_window_draw.remove(Ext.getCmp('myAdd'));
                                            Ext.Msg.show({
                                                title: '成功提示',
                                                msg: respText.msg,
                                                buttons: Ext.Msg.OK,
                                                icon: Ext.Msg.INFO,
                                                width: 200
                                            });
                                            if (isBoss && isNO) {
                                                vp.findByType('treepanel')[0].getNodeById('reviewer-manage').select();
                                                Ext.Ajax.request({
                                                    url: 'js/reviewer/reviewer-manage.js',
                                                    method: 'GET',
                                                    success: onLoadJs
                                                });
                                            }
                                            else {
                                                vp.findByType('treepanel')[0].getNodeById('reviewer-contribute').select();
                                                Ext.Ajax.request({
                                                    url: 'js/reviewer/reviewer-contribute.js',
                                                    method: 'GET',
                                                    success: onLoadJs
                                                });
                                            }
                                            reviewer_ds_draw.load({
                                                params: {
                                                    start: 0,
                                                    limit: 20
                                                }
                                            });
                                        }
                                        else {
                                            reviewer_window_draw.close();
                                            reviewer_window_draw.remove(Ext.getCmp('myAdd'));
                                            Ext.Msg.show({
                                                title: '错误提示',
                                                msg: respText.msg,
                                                buttons: Ext.Msg.OK,
                                                icon: Ext.Msg.ERROR,
                                                width: 200
                                            });
                                        }
                                    },
                                    failure: function(){
                                        Ext.Msg.show({
                                            title: '错误提示',
                                            msg: '查看失败!',
                                            buttons: Ext.Msg.OK,
                                            icon: Ext.Msg.ERROR,
                                            width: 200
                                        });
                                    }
                                    
                                });
                            }
                        }, {
                            text: '取消',
                            handler: function(){
                                reviewer_window_draw.close();
                                reviewer_window_draw.remove(Ext.getCmp('myAdd'));
                            }
                        }]
                    });
                    getFormconfirm(reviewer_form, respText, myhtml);// 获得formPanel的子集里面的第一个对象,也就是fieldSet
                    reviewer_form.doLayout();
                    var reviewer_window_draw = new Ext.Window({
                        closable: false,
                        title: '领稿',
                        width: 600,
                        resizable: false,
                        autoHeight: true,
                        iconCls: 'manuscript',
                        modal: true,
                        constrain: true,
                        closeAction: 'close',
                        items: [reviewer_form]
                    
                    }).show();
                }
                else {
                    var reviewer_form_View = new Ext.FormPanel({
                        border: false,
                        labelAlign: 'right',
                        labelWidth: 100,
                        frame: true,
                        items: [{
                            fieldLabel: '稿件标题',
                            xtype: 'textfield',
                            readOnly: true,
                            itemCls: "unedit",
                            width: 425,
                            value: respText.manuscript.title
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '来稿单位',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.contributeCompany.contributeCompanyName
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '字数',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.manuscript.wordNum
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '要求完成时间',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: plannedConsummationTime
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '字数',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: myWordnum
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '统稿人',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: respText.manuscriptWork.principalName
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textfield',
                            fieldLabel: '小组成员',
                            readOnly: true,
                            itemCls: 'form_text unedit',
                            value: manuscriptWorkerName
                        
                        }, {
                            autoHeight: true,
                            xtype: 'textarea',
                            fieldLabel: '任务描述',
                            readOnly: true,
                            width: 425,
                            itemCls: 'clear unedit',
                            value: respText.manuscriptWork.description
                        
                        }],
                        buttons: [{
                            text: '返回',
                            handler: function(){
                                reviewer_window_drawView.close();
                                reviewer_window_drawView.remove(Ext.getCmp('myAdd'));
                            }
                        }]
                    });
                    getFormconfirm(reviewer_form_View, respText, myhtml);// 获得formPanel的子集里面的第一个对象,也就是fieldSet
                    reviewer_form_View.doLayout();
                    var reviewer_window_drawView = new Ext.Window({
                        closable: false,
                        title: '查看',
                        width: 600,
                        resizable: false,
                        autoHeight: true,
                        iconCls: 'manuscript',
                        modal: true,
                        constrain: true,
                        closeAction: 'close',
                        items: [reviewer_form_View]
                    
                    }).show();
                    
                }
            }
            
        },
        failure: function(){
            Ext.Msg.show({
                title: '错误提示',
                msg: '查看失败!',
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.ERROR,
                width: 200
            });
        }
    });
}

// 拒绝操作START
window.reviewer_refuse = function(needParam){
    Ext.Ajax.request({
        url: 'reviewer_listoneManuscript_view.action',
        method: 'post',
        params: {
            manuscriptId: needParam
        },
        success: function(resp, opts){
            var respText = Ext.util.JSON.decode(resp.responseText);
            if (respText.manuscriptWork.principalId == userId) {
                isBoss = true;
            }
            else {
                isBoss = false;
            }
            if (respText.success) {
            	var reviewer_refuse_form=	new Ext.FormPanel({
                    border: false,
                    labelAlign: 'right',
                    labelWidth: 100,
                    frame: true,
                    items: [{
                        fieldLabel: '稿件标题',
                        xtype: 'textfield',
                        width: 425,
                        readOnly: true,
                        itemCls: 'unedit',
                        value: respText.manuscript.title
                    }, {
                        autoHeight: true,
                        xtype: 'textfield',
                        fieldLabel: '来稿单位',
                        itemCls: 'form_text unedit',
                        readOnly: true,
                        value: respText.contributeCompany.contributeCompanyName
                    }, {
                        autoHeight: true,
                        layout: 'form',
                        xtype: 'textfield',
                        fieldLabel: '字数',
                        itemCls: 'form_text unedit',
                        readOnly: true,
                        value: respText.manuscript.wordNum
                    },{
                    	id: 'rema',
                    	store :new Ext.data.SimpleStore ({
                    		data:[['开会'],['出差'],['休假'],['任务冲突'],['其他']],
                    		fields:['value']
                    	}),
                    	displayField:'value',
                    	valueField:'value',
                    	hiddenName:'remark',
                    	mode:'local',
                    	fieldLabel:'拒绝理由',
                    	triggerAction : 'all',
                    	allowBlank:false,
                    	editable :false,
                    	emptyText :'请选择',
                    	xtype:'combo',
                    	itemCls : 'form_text',
                    	listeners:{
                    		"select":function(obj){
                    			var cmpInputRemake=Ext.getCmp('inputrema');
                    			if(obj.value=="其他"){
                    				cmpInputRemake.setDisabled(false);
                    				cmpInputRemake.setVisible(true);
                    			}else{
                    				cmpInputRemake.setValue('');
                    				cmpInputRemake.setDisabled(true);
                    				obj.show();
                    				cmpInputRemake.setVisible(false);
                    			}
                    		}
                    	} 
                    }, {
                        id: 'inputrema',
                        itemCls: 'clear',
                        width: 425,
                        maxLength: 200,
                        hidden:true,
                        maxLengthText: '输入文字过长,请限制在200字内!',
                        validator: function(value){
                            if (value == "" || value == null) {
                                return false;
                            }
                            else {
                                if (value.indexOf('<') != -1 || value.indexOf('>') != -1) {
                                    return false;
                                }
                                else {
                                    var regex = /[\S]/;
                                    return regex.test(value);
                                }
                            }
                        },
                        invalidText: '输入不合法:不能带<>等特殊符号且不能为空',
                        xtype: 'textarea'
                    }],
                    buttons: [{
                        text: '拒绝',
                        handler: function(){
                    	if(reviewer_refuse_form.form.isValid()){
                    		var remake="";
                        	if(Ext.getCmp("inputrema").isVisible()){
                        		remake=Ext.getCmp("inputrema").getValue();
                        	}else{
                        		remake=Ext.getCmp("rema").getValue();
                        	}
                            Ext.Ajax.request({
                                url: 'reviewer_manuscriptWorkerRejectWork_reject.action',
                                method: 'post',
                                params: {
                                    manuscriptWorkId: respText.manuscriptWork.manuscriptWorkId,
                                    remark: remake,
                                    isBoss: isBoss
                                },
                                success: function(resp, opts){
                                    var respText = Ext.util.JSON.decode(resp.responseText);
                                    if (respText.success) {
                                        reviewer_window_refuse.close();
                                        reviewer_window_refuse.remove(Ext.getCmp('rema'));
                                        Ext.Msg.show({
                                            title: '成功提示',
                                            msg: respText.msg,
                                            buttons: Ext.Msg.OK,
                                            icon: Ext.Msg.INFO,
                                            width: 200
                                        });
                                        vp.findByType('treepanel')[0].getNodeById('reviewer-refuse').select();
                                        Ext.Ajax.request({
                                            url: 'js/reviewer/reviewer-refuse.js',
                                            method: 'GET',
                                            success: onLoadJs
                                        });
                                        
                                        reviewer_ds_draw.load({
                                            params: {
                                                start: 0,
                                                limit: 20
                                            }
                                        });
                                    }
                                    else {
                                        reviewer_window_refuse.close();
                                        reviewer_window_refuse.remove(Ext.getCmp('rema'));
                                        Ext.Msg.show({
                                            title: '错误提示',
                                            msg: respText.msg,
                                            buttons: Ext.Msg.OK,
                                            icon: Ext.Msg.ERROR,
                                            width: 200
                                        });
                                    }
                                },
                                failure: function(){
                                    Ext.Msg.show({
                                        title: '错误提示',
                                        msg: '拒绝失败!',
                                        buttons: Ext.Msg.OK,
                                        icon: Ext.Msg.ERROR,
                                        width: 200
                                    });
                                }
                                
                            });}
                    	else{
                    		if(Ext.getCmp('rema').getValue()==""||Ext.getCmp('rema').getValue()==null){
                    			Ext.Msg.show({
                              title: '错误提示',
                              msg: '拒绝理由不能为空!',
                              buttons: Ext.Msg.OK,
                              icon: Ext.Msg.ERROR,
                              width: 200
                          });
                    	}
                    }
                        }
                    }, {
                        text: '取消',
                        handler: function(){
                            reviewer_window_refuse.close();
                            reviewer_window_refuse.remove(Ext.getCmp('rema'));
                        }
                    }]
                });
                var reviewer_window_refuse = new Ext.Window({
                    iconCls: 'manuscript',
                    closable: false,
                    title: '拒绝领稿',
                    width: 600,
                    resizable: false,
                    autoHeight: true,
                    modal: true,
                    closeAction: 'hide',
                    constrain: true,
                    items: [reviewer_refuse_form]
                
                }).show();
                
            }
        },
        failure: function(){
            Ext.Msg.show({
                title: '错误提示',
                msg: '拒绝失败!',
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.ERROR,
                width: 200
            });
        }
    });
}
// 拒绝操作END
var reviewer_grid_draw = new Ext.grid.GridPanel({
    title: '审核领稿',
    loadMask: {
        msg: '数据加载中...'
    },
    ds: reviewer_ds_draw,
    store: reviewer_ds_draw,
    region: 'center',
    autoScroll: true,
    cm: reviewer_cm_draw,
    autoExpandColumn: 1,
    bbar: new Ext.PagingToolbar({
        pageSize: 20,
        store: reviewer_ds_draw,
        displayInfo: true,
        beforePageText: '第',
        afterPageText: '页-共{0}页',
        displayMsg: '显示{0} - {1} 条  共 {2} 条',
        emptyMsg: "没有记录"
    })
});
reviewer_ds_draw.load({
    params: {
        start: 0,
        limit: 20
    }
});
var reviewer_p_draw = {
    id: 'reviewer-draw',
    border: false,
    layout: 'border',
    items: [reviewer_grid_draw]
};
Ext.getCmp('content-panel').add(reviewer_p_draw);
Ext.getCmp('content-panel').layout.setActiveItem('reviewer-draw');
